<?php use_helper('DateForm') ?>
<?php use_helper('Object') ?>
<?php use_javascript('jquery-1.3.2.min.js') ?> 
<?php use_javascript('tablesorter/jquery-latest.js') ?> 
<?php use_javascript('tablesorter/jquery.tablesorter.js') ?> 
<?php use_javascript('jquery.maskedinput-1.2.2.min.js') ?> 
<?php include_javascripts() ?> 

	<link rel="stylesheet" href="../js/tablesorter/themes/blue/style.css" type="text/css" media="print, projection, screen" />

	<script type="text/javascript">
	    $(function() {		
		    $("#tablesorter").tablesorter({
		        widgets: ['zebra']
		    });
	    });	

		$(function () {
			$("#pesquisar").click(function () {

				switch ($("input[name='tp_saida_excel']:checked").val()) {
					case '0':
						$('#result_relatorio').html('<?php echo image_tag('carregando.gif', 'alt=carregando...')."  Carregando..." ?>');
						$.ajax({
							type: "POST"
							, url: "<?php echo url_for('relatorio/resultado') ?>"
							, data: $('#id_form').serializeArray()
							, dataType: "html"
							, success: function(data){
								$('#result_relatorio').hide();
								$('#result_relatorio').html(data);
								$('#result_relatorio').show("slow");
							}
							, error: function(){ $('#result_relatorio').html('Erro! <?php echo sfConfig::get('app_msg_enviar_tela_gestor')?>'); }
						});
						break;
					case '1':
						$("form:first").submit();
						break;
				}
				
			});
		});

		$(document).ready(function(){
			$("#dt_start").mask("99/99/9999");
			$("#dt_end").mask("99/99/9999");
		});

	</script>
    
<div id="formulario" style="width: 90%">
	
    <?php echo form_tag('relatorio/resultado', 'method=post multipart=true id=id_form') ?>
        <table width="100%">
            <tbody>
                <tr>
                    <th>Saída:</th>
                    <td colspan="2"><input type="radio" checked="checked" size="12" value="0" name="tp_saida_excel" />Em tela
                        <input type="radio" size="12" value="1" name="tp_saida_excel" />Planilha
                    </td>
                </tr>
                <tr>
                    <th>Tipo:</th>
                    <td colspan="2"><input type="radio" checked="checked" size="12" value="1" name="tp_relatorio" />Sintético
                        <input type="radio" size="12" value="2" name="tp_relatorio" />Analítico
                    </td>
                </tr>
                <tr>
                    <th rowspan="3">Filtros: </th>
                    <th>Limite Conclusão: </th>
                    <td>
                        Início:
						  <?php echo input_date_tag('dt_start', '', array('rich' => true, 'culture' => 'pt', 'calendar_button_txt' => image_tag('calendario.gif'), 'format' => 'dd/MM/Y')); ?>
                          &nbsp;&nbsp;&nbsp;
					    Fim:
						  <?php echo input_date_tag('dt_end', '', array('rich' => true, 'culture' => 'pt', 'calendar_button_txt' => image_tag('calendario.gif'), 'format' => 'dd/MM/Y')); ?>

                    </td>
                </tr>
                <tr>
                    <th>Câmara:</th>
                    <td>
                        <select name="cd_camara" id="cd_camara">
							<option value=""></option>
							<?php echo objects_for_select($camara_list, 'getCdCamara', 'getName') ?>
						</select>
                    </td>
                </tr>
				<?php if ($sf_user->getAttribute('gerente',null,'usr')) : ?>
					<tr>
						<th>Secretário:</th>
						<td>
							<select name="cd_usuario" id="cd_usuario">
								<option value=""></option>
								<?php echo objects_for_select($usuario_list, 'getCdUsuario', 'getName') ?>
							</select>
						</td>
					</tr>
				<?php endif; ?>
                <tr>
                    <th>Agrupador:</th>
                    <td colspan="2"><input type="radio" checked="checked" size="12" value="1" name="tp_agrupador" />Câmara
                        <input type="radio" size="12" value="2" name="tp_agrupador" />Secretário
                    </td>
                </tr>

            </tbody>

        </table>
		
		<p><a href="#" id="pesquisar" class="link_btn">Pesquisar</a>
		
        <input class="btn" type="reset" value="Limpar" name="Reset" /> 
    </form>
	<center>
	<div id="result_relatorio" style="text-aling: center;"></div>

</div>
